package com.leochan.shuniu.api;

import org.scribe.encoders.URLHelper;
import org.scribe.http.Request;
import org.scribe.http.Response;
import org.scribe.http.Verb;
import org.scribe.oauth.Token;

import com.leochan.shuniu.Global;
import com.leochan.utils.DebugUtils;

public class LikeByAPI extends BaseAPI {

	private static final String liked_by_current_str = "http://api.shuniu.net/api/v1/messages/liked_by/current.json%s";

	private static final String Message_id = "message_id";

	// POST http://api.shuniu.net/api/v1/messages/liked_by/current.json
	public static void messages_liked_by_current_POST(Token token,
			long network_id, long message_id, long user_id) {
		DebugUtils.printLogD();
		initParams(token);
		if (network_id != -1) {
			params.put(Network_id, network_id);
		}
		params.put(Message_id, message_id);
		params.put(User_id, network_id);
		String format = String.format(liked_by_current_str,
				URLHelper.queryString(params));
		DebugUtils.printLogD(format);
		Request req = new Request(Verb.POST, format);
		Response resp = req.send(Global.proxy);
		DebugUtils.printLogD(resp.getBody());
		DebugUtils.printLogD("====================================");
	}

	// DELETE http://api.shuniu.net/api/v1/messages/liked_by/current.json
	public static void messages_liked_by_current_DELETE(Token token,
			long network_id, long message_id, long user_id) {
		DebugUtils.printLogD();
		initParams(token);
		if (network_id != -1) {
			params.put(Network_id, network_id);
		}
		params.put(Message_id, message_id);
		params.put(User_id, network_id);
		String format = String.format(liked_by_current_str,
				URLHelper.queryString(params));
		DebugUtils.printLogD(format);
		Request req = new Request(Verb.DELETE, format);
		Response resp = req.send(Global.proxy);
		DebugUtils.printLogD(resp.getBody());
		DebugUtils.printLogD("====================================");
	}
}
